import request from '@/utils/request'

export const reqSpuList = (page, limit, category3Id) => {
  // return request.get(`/admin/product/${page}/${limit}?category3Id=${category3Id}`)
  return request.get(`/admin/product/${page}/${limit}`, {
    params: { category3Id }
  })
}
// 品牌：/admin/product/baseTrademark/getTrademarkList
// 销售属性：/admin/product/baseSaleAttrList
// 获取某个spu的信息：/admin/product/getSpuById/{spuId}
// 获取某个spu的信息：/admin/product/spuImageList/{spuId}

export const reqSpu = (spuId) => {
  return request.get(`/admin/product/getSpuById/${spuId}`) // 获取spu信息
}
export const reqTradeMarkList = () => {
  return request.get('/admin/product/baseTrademark/getTrademarkList') // 获取品牌的信息
}
export const reqSpuImageList = (spuId) => {
  return request.get(`/admin/product/spuImageList/${spuId}`) // 获取spu的图片
}
export const reqBaseSaleAttrList = () => {
  return request.get('/admin/product/baseSaleAttrList') // 获取平台的销售属性---一共三个
}

// export const reqSaveSpuInfo = () =>{
//     return request.post('/admin/product/saveSpuInfo',data) //添加spu
// }

// 修改spu|添加spu，对于修改或者添加唯一区别是携带的参数是否带id /admin/product/saveSpuInfo /admin/product/updateSpuInfo
export const reqAddOrUpdateSpu = (spuInfo) => {
  if (spuInfo.id) {
    // 带id的，修改spu接口
    return request.post('/admin/product/updateSpuInfo', spuInfo)
  } else {
    // 添加spu接口
    return request.post('/admin/product/saveSpuInfo', spuInfo)
  }
}
export const reqDeleteSpu = (spuId) => {
  return request.delete(`/admin/product/deleteSpu/${spuId}`) // 删除spu
}
